package com.example.utils;

import java.io.Serializable;

/***
 *
 * 响应包
 */
public class Pong implements Serializable {

    //消息id
    private String id;

    //接收时间戳
    private long fromTimeStamp;

    //返回时间戳
    private long toTimeStamp;

    public Pong(String id, long toTimeStamp) {
        this.id = id;
        this.toTimeStamp = toTimeStamp;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public long getFromTimeStamp() {
        return fromTimeStamp;
    }

    public void setFromTimeStamp(long fromTimeStamp) {
        this.fromTimeStamp = fromTimeStamp;
    }

    public long getToTimeStamp() {
        return toTimeStamp;
    }

    public void setToTimeStamp(long toTimeStamp) {
        this.toTimeStamp = toTimeStamp;
    }

    //刷新属性
    public void recalculateFields() {
        this.toTimeStamp = System.currentTimeMillis();
    }

    @Override
    public String toString() {
        return "Pong{" +
                "id='" + id + '\'' +
                ", fromTimeStamp=" + fromTimeStamp +
                ", toTimeStamp=" + toTimeStamp +
                '}';
    }
}
